// 
// File:   prism_token_parser.h
// Author: cionescu
//
// Created on 10 January 2007, 20:36
//

#ifndef _prism_token_parser_H
#define	_prism_token_parser_H
#include <boost/spirit/core.hpp>
#include "prism_actions.h"
#include "prism_tokens.h"

struct typed_parser : public char_parser<typed_parser>
{
    typedef typed_parser self_t;
    int m_type;

    typed_parser(int _type):m_type (_type){}

    template <typename CharT>
    bool test(CharT ch) const
    { 
        //ch->print_token();
        return ch->get_type()==m_type; 
    }
    
};

typed_parser const ident_p = typed_parser(IDENT_TT);

typed_parser const const_p = typed_parser(CONST_TT);

template <typename CharT = char>
struct token_p : public char_parser<token_p<CharT> >{
    token_p(CharT ch_)
    : ch(ch_) {}

    template <typename T>
    bool test(T ch_) const
    { 
        //ch_->print_token();
        //ch->print_token();
        return ch_ == ch; 
    }

    CharT   ch;
};
    
struct null_parser : public char_parser<null_parser>{
    typedef null_parser self_t;

    null_parser() {}

    template <typename CharT>
    bool test(CharT ch) const
    { 
        return false; 
    }
};

null_parser const space_token_p = null_parser();

#endif	/* _prism_token_parser_H */

